//综合业务查询

import { domainService } from '~/config/server'
import { NetService } from '~/utils/net.service'
import { Inject, Debounce } from "~/core/decorator";
import { FilterService } from '~/utils/filter.service';

export class SynthesizeQueryService {

    @Inject(NetService)
    private netService: NetService

    /**
     * 查询案件流转记录
     */
    public queryCaseTurnRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseTurnRecord,
            data: {
                caseNumber: data.caseNumber,   // 借据号
                triggerAction: data.triggerAction,
                turnSource:data.turnSource,
                turnType: data.turnType,
                deptName:data.deptName[data.deptName.length-1],
                lastCollectorName: data.lastCollectorName,
                currentCollectorName: data.currentCollectorName,
                caseTurnTimeMin: FilterService.dateRanageFormat(data.caseTurnTime).start, // 案件流入时间
                caseTurnTimeMax: FilterService.dateRanageFormat(data.caseTurnTime).end,
            },
            page,
            sort
        })
    }

    /**
     * 委外案件查询
     */
    public queryCaseOutRecords(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseOutRecords,
            data: {
                caseNumber: data.caseNumber,
                outBatch: data.outBatch,
                outsourceId: data.outsourceId,
                personalName: data.personalName,
                idCard: data.idCard,
                outTimeMin: FilterService.dateRanageFormat(data.outTime).start,
                outTimeMax: FilterService.dateRanageFormat(data.outTime).end,
                outEndDateMin: FilterService.dateRanageFormat(data.outEndDate).start,
                outEndDateMax: FilterService.dateRanageFormat(data.outEndDate).end,
            },
            page,
            sort
        })
    }

    /**
     * inBound查询
     */
    public inboundQuery(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.inBoundQuery,
            data: {
                caseNumber: data.caseNumber,
                personalName: data.personalName,
                mobileNo: data.mobileNo,
                idCard: data.idCard,
                // area: data.area.length === 0 ? '' : data.area[data.area.length - 1],
                provinceId: data.area[0],
                cityId: data.area[1],
                countyId: data.area[2],
                overdueAmountMin: data.overdueAmount.min,
                overdueAmountMax: data.overdueAmount.max,
                currentCollectorRealName: data.currentCollectorRealName,
                collectionStatus: data.collectionStatus,
                overduePeriod: data.overduePeriod,
                overdueDaysMin: data.overdueDays.min,
                overdueDaysMax: data.overdueDays.max,
            },
            page,
            sort
        })
    }

    /**
     * 锁定催收员
     */
    public bindLockingCollector(caseId) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.bindLockingCollector,
            data : {
                caseId
            }
            
        })
    }

    /**
     * 短信发送查询
     */
    public queryMessageSendRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryMessageSendRecord,
            data: {
                caseNumber: data.caseNumber,
                mobileNo: data.mobileNo,
                sendCategory:data.sendCategory,
                messageStatus: data.messageStatus,
                operatorRealName: data.operatorRealName,
                createTimeMin: FilterService.dateRanageFormat(data.createTime).start,
                createTimeMax: FilterService.dateRanageFormat(data.createTime).end
            },
            page,
            sort
        })
    }

    /**
     * 实时还款查询
     */
    public queryRepaymentRecord(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryRepaymentRecord,
            data: {
                deptCode: data.deptCode,
                collectorId: data.collectorId,
                caseType: data.caseType,
                sysCode: data.sysCode,
                caseNumber:data.caseNumber,
				personalName:data.personalName,
				repaymentTimeMin: FilterService.dateRanageFormat(data.repaymentTime).start, // 案件流入时间
				repaymentTimeMax: FilterService.dateRanageFormat(data.repaymentTime).end
            },
            page,
            sort
        })
    }

    /**
     * 实时还款查询 -> 还款总金额查询
     */
    public getTotalRepayment(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getTotalRepayment,
            data: {
                deptCode: data.deptCode,
                collectorId: data.collectorId,
                caseType: data.caseType,
                sysCode: data.sysCode,
                caseNumber:data.caseNumber,
				personalName:data.personalName,
				repaymentTimeMin: FilterService.dateRanageFormat(data.repaymentTime).start, // 案件流入时间
				repaymentTimeMax: FilterService.dateRanageFormat(data.repaymentTime).end
            }
        })
    }

    /**
     * 策略分案数据查询列表
     */
    public queryCaseDistributeData(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.queryCaseDistributeData,
            data: {
                strategyName: data.strategyName,
                caseNumber: data.caseNumber,
                departmentType: data.departmentType,
                distributeDateMin: FilterService.dateRanageFormat(data.distributeDate).start,
                distributeDateMax: FilterService.dateRanageFormat(data.distributeDate).end
            },
            page,
            sort
        })
    }

    /**
     * 案件查询
     */
    public caseSearch(data, page?, sort?) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearch,
            data: {
                caseNumber: data.caseNumber,
                personalName: data.personalName,
                mobileNo: data.mobileNo,
                idCard: data.idCard,
                // area: data.area.length === 0 ? '' : data.area[data.area.length - 1],
                provinceId: data.area[0],
                cityId: data.area[1],
                countyId: data.area[2],
                overdueAmountMin: data.overdueAmount.min,
                overdueAmountMax: data.overdueAmount.max,
                collectorRealName: data.currentCollectorRealName,
                collectionStatus: data.collectionStatus,
                overduePeriod: data.overduePeriod,
                overdueDaysMin: data.overdueDays.min,
                overdueDaysMax: data.overdueDays.max,
                sysCode: data.sysCode,
                productName: data.productName,
                deptId:data.deptIds,
                departmentType:data.departmentType,
                personalLabel:data.personalLabel,
            },
            page,
            sort
        })
    }

    /**
     * 案件导出
     */
    public caseSearchExportCase(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearchExportCase,
            data: {
                caseIds: data.caseIds,
                caseNumber: data.caseNumber,
                personalName: data.personalName,
                mobileNo: data.mobileNo,
                idCard: data.idCard,
                // area: data.area.length === 0 ? '' : data.area[data.area.length - 1],
                provinceId: data.area[0],
                cityId: data.area[1],
                countyId: data.area[2],
                overdueAmountMin: data.overdueAmount.min,
                overdueAmountMax: data.overdueAmount.max,
                collectorRealName: data.currentCollectorRealName,
                collectionStatus: data.collectionStatus,
                overduePeriod: data.overduePeriod,
                overdueDaysMin: data.overdueDays.min,
                overdueDaysMax: data.overdueDays.max,
                sysCode: data.sysCode,
                productName: data.productName,
                deptId:data.deptIds,
                personalLabel:data.personalLabel,
            }
        })
    }

    /**
     * 催记导出
     */
    public caseSearchExportFollow(data) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.caseSearchExportFollow,
            data: {
                caseIds: data.caseIds,
                caseNumber: data.caseNumber,
                personalName: data.personalName,
                mobileNo: data.mobileNo,
                idCard: data.idCard,
                // area: data.area.length === 0 ? '' : data.area[data.area.length - 1],
                provinceId: data.area[0],
                cityId: data.area[1],
                countyId: data.area[2],
                overdueAmountMin: data.overdueAmount.min,
                overdueAmountMax: data.overdueAmount.max,
                collectorRealName: data.currentCollectorRealName,
                collectionStatus: data.collectionStatus,
                overduePeriod: data.overduePeriod,
                overdueDaysMin: data.overdueDays.min,
                overdueDaysMax: data.overdueDays.max,
                sysCode: data.sysCode,
                productName: data.productName,
                deptId:data.deptIds,
                personalLabel:data.personalLabel,
            }
        })
    }
    /**
     * 核销案件查询
     */
    public getVerifyInfo(data,page) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getVerifyInfo,
            data,
            page
        })
    }
    /**
     * 费用减免查询/展期申请查询
     */
    public getDerateInfo(data,page) {
        return this.netService.send({
            server: domainService.synthesizeQueryController.getDerateInfo,
            data:{
                applyTimeStart:FilterService.dateRanageFormat(data.applyTime).start,
                applyTimeEnd:FilterService.dateRanageFormat(data.applyTime).end,
                caseNumber:data.caseNumber,
                applyRealName:data.applyRealName,
                sysCode:data.sysCode,
                applyStatus:data.applyStatus,
                type:data.type
            },
            page
        })
    }
       
}